package allTests;


import abbot.finder.ComponentNotFoundException;
import abbot.finder.MultipleComponentsFoundException;
import abbot.finder.matchers.ClassMatcher;
import abbot.finder.matchers.NameMatcher;
import abbot.util.AWTFixtureHelper;
import com.supermap.data.Datasource;
import com.supermap.desktop.controls.ControlsProperties;
import com.supermap.desktop.core.properties.CharsetProperties;
import com.supermap.desktop.core.properties.CoreProperties;
import com.supermap.desktop.core.utilties.SystemPropertyUtilities;
import com.supermap.desktop.process.ProcessProperties;
import com.supermap.desktop.process.tasks.TasksManager;
import compareResult.datasetCompare.FileComparer;
import operation.*;
import org.junit.*;
import org.junit.rules.ErrorCollector;
import org.junit.runner.RunWith;
import org.junit.runners.BlockJUnit4ClassRunner;
import robotCross.CrossRobot;
import robotCross.TextMatcher;
import robotCross.TipMatcher;
import socketEnv.CrossProperties;
import socketEnv.DataUtil;
import util.FileUtil;
import util.Info;
import util.Platform;

import javax.swing.*;
import java.awt.*;
import java.util.Iterator;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import static operation.Operation.robot;
import static operation.RibbonOperation.RIBBONOPERATION;


/**
 * Created by hanyz on 2016/8/30.
 */
@RunWith(BlockJUnit4ClassRunner.class)
public class TestConversion {
	@Rule
	public final ErrorCollector errorCollector = new ErrorCollector();
	CompareOperation compareOperation = CompareOperation.getInstance(errorCollector);
	@Before
	public void runBeforeTestMethod() {
		Info.out("@Before - runBeforeTestMethod");
		Operation.helper = new AWTFixtureHelper();
		Operation.robot = Operation.helper.getRobot();
		DialogOperation.closeAllDialog();
		Operation.datasources.clear();
	}

	@After
	public void runAfterTestMethod() throws Exception {
		Info.out("@After - runAfterTestMethod");
		Operation.releaseDatasources();
		DialogOperation.closeAllDialog();
		WorkspaceTreeOperation.closeWorkspace();
	}

	@Test
//    @Description("导入shp线数据，并新建数值型字段lineWidth")
	public void testImportSHP() throws Exception {
		String filePath = DataUtil.testDataPath + "ImportData/ArcGIS/line.shp";
		String resultDsPath = DataUtil.resultPath_actual + "ImportData/testImportSHP/testImportSHP.udb";
		String expDsPath = DataUtil.resultPath_exp + "ImportData/testImportSHP/testImportSHP.udb";

		//导入数据
		CommonOperation.createUDB(resultDsPath);//新建文件数据源
		new WorkspaceTreeOperation().selectDatasouceNodeMenu("testImportSHP", "导入数据集...");
		new ImportDataOperation().addImportFile(filePath);
		DialogOperation dialogOperation = new DialogOperation();
		dialogOperation.setComboBoxSelectedItem(new NameMatcher("PanelSourceInfo_comboBoxCharset"), "CHINESE_GB18030");
		dialogOperation.clickComponent(new NameMatcher("DataImportDialog_buttonImport"));
		new CommonOperation().waitForProgressDispose(60000);

		//设置属性字段
		new WorkspaceTreeOperation().selectDatasetNodeMenu("testImportSHP", "line", "属性");
		DockbarOperation dockbarOperation = new DockbarOperation("属性");
		dockbarOperation.clickTab("字段");
		dockbarOperation.clickComponent(new NameMatcher("RecordsetPropertyControl_buttonAdd"));
		JTable jtable = ((JTable) dockbarOperation.searchComponent(new ClassMatcher(JTable.class)));
		int row = jtable.getRowCount() - 1;
		new TableOperation(jtable).setCellValue(row, "名称", "lineWidth");
		new TableOperation(jtable).setCellValue(row, "类型", "单精度");
		new TableOperation(jtable).setCellValue(row, "缺省值", "0.5");
		dockbarOperation.clickComponent(new NameMatcher("RecordsetPropertyControl_buttonApply"));
		//结果数据集对比
		Datasource resultDatasource = CommonOperation.getDatasource(0);
		Datasource expDatasource = CommonOperation.openDatasource(expDsPath);
		boolean compareResult = compareOperation.compareDataset(resultDatasource, expDatasource);
		Assert.assertTrue(compareResult);
	}

	@Test
	/**
	 * CSV Dialog
	 */
	public void testImportCSV_D() throws Exception {
		String[] fileNames = {"ImportData/CSV/ChinaPOI.csv", "ImportData/CSV/County_P.csv"};
		String resultDsPath = DataUtil.resultPath_actual + "ImportData/testImportCSV/testImportCSV.udb";
		String expDsPath = DataUtil.resultPath_exp + "ImportData/testImportCSV/testImportCSV.udb";
		CommonOperation.createUDB(resultDsPath);//新建文件数据源
		new WorkspaceTreeOperation().selectDatasouceNodeMenu("testImportCSV", "导入数据集...");
		for (String fileName : fileNames) {
			String filePath = DataUtil.testDataPath + fileName;
			new ImportDataOperation().addImportFile(filePath);
		}
		String dialogTitle = "数据导入";
		DialogOperation dialogOperation = new DialogOperation(dialogTitle);
		Component jTable = dialogOperation.searchComponent(new NameMatcher("DataImportDialog_table"));
		new TableOperation((JTable) jTable).selectRow(1);
		//勾选首行为字段信息
		dialogOperation.clickComponent(new NameMatcher("PanelTransformForMicrosoft_checkBoxFirstRowAsField"));
		//Linux上设置字符集为GB18030
		dialogOperation.setComboBoxSelectedItem(new NameMatcher("PanelSourceInfo_comboBoxCharset"), "CHINESE_GB18030");
		new TableOperation((JTable) jTable).selectRow(0);
		dialogOperation.setComboBoxSelectedItem(new NameMatcher("PanelSourceInfo_comboBoxCharset"), "CHINESE_GB18030");
		dialogOperation.clickComponent(new NameMatcher("DataImportDialog_buttonImport"));
		new CommonOperation().waitForProgressDispose(60000);

		//结果数据集对比
		Datasource resultDatasource = CommonOperation.getDatasource(0);
		Datasource expDatasource = CommonOperation.openDatasource(expDsPath);
		boolean compareResult = compareOperation.compareDataset(resultDatasource, expDatasource);
		Assert.assertTrue(compareResult);
	}

	@Test
	public void testImportTiff() throws Exception {
		String[] fileNames = {"erhai.tif", "4bands16bit.tif"};
		String filePath = DataUtil.testDataPath + "ImportData/images/";
		String tfwFilePath = filePath + "erhai.tfw";
		String resultDsPath = DataUtil.resultPath_actual + "ImportData/testImportTiff/testImportTiff.udb";
		String expDsPath = DataUtil.resultPath_exp + "ImportData/testImportTiff/testImportTiff.udb";

		//导入数据
		CommonOperation.createUDB(resultDsPath);//新建文件数据源
		new WorkspaceTreeOperation().selectDatasouceNodeMenu("testImportTiff", "导入数据集...");
		new ImportDataOperation().addImportFiles(filePath, fileNames);
		Operation.robot.delay(1000);
		String dialogTitle = "数据导入";
		DialogOperation dialogOperation = new DialogOperation(dialogTitle);
		Component jTable = dialogOperation.searchComponent(new NameMatcher("DataImportDialog_table"));
		new TableOperation((JTable) jTable).selectRows(0, 1);
		//导入为多波段
		dialogOperation.setComboBoxSelectedItem(new NameMatcher("PanelTransformForImage_comboBoxBandImportModel"), "多波段");
		new TableOperation((JTable) jTable).selectRow(1);
		//洱海数据选择坐标系文件
		dialogOperation.clickComponent(new NameMatcher("FileChooserControl_button"));
		new JFileChooserOperation(600000).chooseFile(tfwFilePath);
		dialogOperation.clickComponent(new NameMatcher("DataImportDialog_buttonImport"));
		new CommonOperation().waitForProgressDispose(60000);
		//创建影像金字塔，使用目前的组件版本，执行后面代码桌面会崩溃，等组件修改完毕，在开启后面步骤
//		new WorkspaceTreeOperation().selectDatasetNodeMenu("testImportTiff", "T4bands16bit|erhai", "创建影像金字塔");
//		new CommonOperation().waitForProgressDispose(60000);
//
//		//结果数据集对比
//		Datasource resultDatasource = CommonOperation.getDatasource(0);
//		Datasource expDatasource = CommonOperation.openDatasource(expDsPath);
//		boolean compareResult = CommonOperation.compareDataset(expDatasource, resultDatasource);
//		Assert.assertTrue(compareResult);
	}

	@Test
	public void testSQLQuery() throws Exception {
		String testDsPath = "DataConversion/testSQLQuery/SQLQuery.udb";
		String expDsPath = DataUtil.resultPath_exp + "DataConversion/testSQLQuery/SQLQuery.udb";

		//需要做属性更新，修改数据源，先复制数据源
		DataUtil.copyUDB(testDsPath);
		//打开数据源，UI
		CommonOperation.openUDB(DataUtil.localDataPath + testDsPath);

		//查询“黄河”，显示地图，并保存数据集
		new WorkspaceTreeOperation().selectDatasetNodeMenu("SQLQuery", "Main_River_pg", "SQL查询...");
		DialogOperation dialogOperation = new DialogOperation("SQL查询");
		Component tableFieldInfo = dialogOperation.searchComponent(new NameMatcher("JDialogSQLQuery_tableFieldInfo"));
		TableOperation tableOperation = new TableOperation((JTable) tableFieldInfo);
		//查询所有字段
		tableOperation.selectRow(0);
		new CrossRobot().doubleClick();
		//编辑查询条件
		String queryCondition = "Main_River_pg.NAME Like \'黄河\'";
		dialogOperation.setTextComponentValue(new NameMatcher("JDialogSQLQuery_textareaQueryCondition"), queryCondition);
		dialogOperation.clickComponent(new NameMatcher("JDialogSQLQuery_checkBoxShowTabular"));//不浏览属性表
		dialogOperation.clickComponent(new NameMatcher("JDialogSQLQuery_checkBoxHighLigthMap"));//地图中高亮
		dialogOperation.clickComponent(new NameMatcher("PanelSaveSearchResult_checkBoxSaveResult"));//保存查询结果
		dialogOperation.setTextComponentValue(new NameMatcher("PanelSaveSearchResult$InsidePanel_textFieldDataset"), "YellowRiver");//设置结果名称
		dialogOperation.clickComponent(new NameMatcher("JDialogSQLQuery_buttonQuery"));
		Operation.robot.delay(2000);//等待对话框消失和地图加载

		//查询geometry size大于100000的河流，更新其属性，设置前景色字段值
		new WorkspaceTreeOperation().selectDatasetNodeMenu("SQLQuery", "Main_River_pg", "SQL查询...");
		dialogOperation = new DialogOperation("SQL查询");
		dialogOperation.clickComponent(new NameMatcher("JDialogSQLQuery_buttonClear"));
		tableFieldInfo = dialogOperation.searchComponent(new NameMatcher("JDialogSQLQuery_tableFieldInfo"));
		tableOperation = new TableOperation((JTable) tableFieldInfo);
		//查询“foreColor”字段
		tableOperation.selectRow(12);
		new CrossRobot().doubleClick();
		//编辑查询条件 Main_River_pg.SmSdriN > 10000
		dialogOperation.clickComponent(new NameMatcher("JDialogSQLQuery_textareaQueryCondition"));
		tableOperation.selectRow(9);
		new CrossRobot().doubleClick();
		dialogOperation.setComboBoxSelectedItem(new NameMatcher("JDialogSQLQuery_jComboBoxOperator"), "<");
		Operation.robot.keyString("10000");
		dialogOperation.clickComponent(new NameMatcher("JDialogSQLQuery_buttonQuery"));
		Operation.robot.waitForIdle();
		//属性表更新列
		TabularOperation tabularOperation = new TabularOperation();
		tabularOperation.getTableOperation().clickTableCell(0, 1);
		tabularOperation.clickRightButtonMenuItem("更新列");
		DialogOperation dialogOperation1 = new DialogOperation("/更新列.*/");
		dialogOperation1.clickComponent(new NameMatcher("JDialogTabularUpdateColumn_radioButtonUpdateColumn"));
		dialogOperation1.setTextComponentValue(new NameMatcher("JDialogTabularUpdateColumn_textAreaOperationEQ"),"-308881");
		dialogOperation1.clickComponent(new NameMatcher("JDialogTabularUpdateColumn_buttonApply"));
		dialogOperation1.closeContainer();

		//结果数据集对比
		Datasource resultDatasource = CommonOperation.getDatasource(0);
		Datasource expDatasource = CommonOperation.openDatasource(expDsPath);
		boolean compareResult = compareOperation.compareDataset(expDatasource, resultDatasource);
		Assert.assertTrue(compareResult);
	}

	@Test
	public void testTabular() throws Exception {
		String[] fileNames = {"SampleData/City/Changchun.udb", "SampleData/City/Changchun.udd"};
		String dataSourceName = "打开文件型数据源...";
		new WorkspaceTreeOperation().selectTheDatasouceNodeMenu(dataSourceName);
		Operation.robot.delay(2000);
		new JFileChooserOperation().chooseFile(DataUtil.testDataPath + fileNames[0]);
		Operation.robot.delay(2000);
		new WorkspaceTreeOperation().selectDatasetNodeMenu("Changchun", "Park", "浏览属性表");
		Operation.robot.delay(3000);
		TableOperation tabular = new TableOperation();
		tabular.getTabularCellValue(1, 6);
		tabular.setTabularCellValue("1222", 1, 6);
		String str = tabular.getTabularCellValue(1, 6);
		System.out.println(str);
		tabular.clickTableCell(2, 8);
		RIBBONOPERATION.clickButton("属性表", "升序");
		Operation.robot.delay(2000);
	}


	@Test
	@Platform
	//该用例只在windows上执行。linux不支持导入dxf
	public void testImportModelDxf_D() throws Exception {
		String[] fileNames = {"ImportData/images/JingjinImage.tif", "ImportData/3D/New_CAD.dxf", "ImportData/3D/New_CAD.dxf"};
		String resultDsPath = DataUtil.resultPath_actual + "ImportData/testImportModelDxf/testImportModelDxf_D.udb";
		String expDsPath = DataUtil.resultPath_exp + "ImportData/testImportModelDxf/testImportModelDxf_D.udb";

		CommonOperation.createUDB(resultDsPath);//新建文件数据源
		new WorkspaceTreeOperation().selectDatasouceNodeMenu("testImportModelDxf_D", "导入数据集...");
		Operation.robot.delay(2000);
		for (String fileName : fileNames) {
			String filePath = DataUtil.testDataPath + fileName;
			new ImportDataOperation().addImportFile(filePath);
		}
		String dialogTitle = "数据导入";
		Component jTable = new DialogOperation("数据导入").searchComponent(new NameMatcher("DataImportDialog_table"));
		new TableOperation((JTable) jTable).selectRow(0);
		DialogOperation dialogOperation = new DialogOperation(dialogTitle);
		dialogOperation.clickComponent(new NameMatcher("DataImportDialog_buttonDelete"));
		dialogOperation.clickComponent(new NameMatcher("DataImportDialog_buttonSelectAll"));
		dialogOperation.clickComponent(new NameMatcher("DataImportDialog_buttonInvertSelect"));
		new TableOperation((JTable) jTable).setCellValue(1, 1, "三维模型文件");
		dialogOperation.clickComponent(new NameMatcher("DataImportDialog_buttonImport"));
		new CommonOperation().waitForProgressDispose(60000);

		//结果数据集对比
		Datasource resultDatasource = CommonOperation.getDatasource(0);
		Datasource expDatasource = CommonOperation.openDatasource(expDsPath);
		boolean compareResult = compareOperation.compareDataset(resultDatasource, expDatasource);
		Assert.assertTrue(compareResult);
	}

	@Test
	@Platform
	//该用例只在windows上执行。linux导出的csv和windows上导出的POI精度不同，比不过。后面需要单独加数据。
	public void testExportData() throws Exception {
		String[] fileNames = {"SampleData/City/Changchun.udb", "SampleData/City/Changchun.udd", "SampleData/City/Jingjin.udb", "SampleData/City/Jingjin.udd"};
		String exportPath = DataUtil.resultPath_actual + "DataConversion/testExportData/";
		String[] resultFiles = new String[]{exportPath + "BaseMap_L.csv", exportPath + "BaseMap_P.csv", exportPath + "Factory.csv", exportPath + "Neighbor_L.csv",
				exportPath + "Vegetable.dbf", exportPath + "Vegetable.shp"};
		FileUtil.delete(exportPath);//删除旧文件

		String dataSourceName = "打开文件型数据源...";
		new WorkspaceTreeOperation().selectTheDatasouceNodeMenu(dataSourceName);
//		Operation.robot.delay(2000);
		new JFileChooserOperation().chooseFile(DataUtil.testDataPath + fileNames[2]);
//		Operation.robot.delay(2000);
		new WorkspaceTreeOperation().selectTheDatasouceNodeMenu(dataSourceName);
		new JFileChooserOperation().chooseFile(DataUtil.testDataPath + fileNames[0]);
//		Operation.robot.delay(2000);
		new WorkspaceTreeOperation().selectDatasetNodeMenu("Changchun", "Factory|Park|Vegetable", "导出数据集...");
//		Operation.robot.delay(3000);
		DialogOperation dialogOperation = new DialogOperation("数据导出");
		new TableOperation().clickDialogTableRow("数据导出", 0, 0);
		dialogOperation.clickComponent(new NameMatcher("DataExportDialog_buttonDelete"));
		dialogOperation.clickComponent(new NameMatcher("DataExportDialog_buttonInvertSelect"));
		dialogOperation.clickComponent(new NameMatcher("DataExportDialog_buttonAddDataset"));
//		Operation.robot.delay(2000);
		JTree workspaceTree = (JTree) new DialogOperation("选择").searchComponent(new ClassMatcher(JTree.class));
		new WorkspaceTreeOperation(workspaceTree).selectDatasourceNode("Jingjin");
//		Operation.robot.delay(2000);
		new TableOperation().clickDialogTableRow("选择", 2, 5);
		new DialogOperation("选择").clickComponent(new TipMatcher("确定"));
//		Operation.robot.delay(5000);
		Component jTable = new DialogOperation("数据导入").searchComponent(new NameMatcher("DataExportDialog_tableExport"));
		new TableOperation((JTable) jTable).setCellValue(1, 1, "ArcGIS Shape 文件");

		//设置导出路径
		String dialogTitle = "数据导出";
		new DialogOperation(dialogTitle).clickComponent(new NameMatcher("DataExportDialog_buttonSelectAll"));
		new DialogOperation(dialogTitle).clickComponent(new NameMatcher("DataExportDialog_buttonExportsSet"));
		Operation.robot.delay(1000);
		dialogTitle = "统一设置";
		new DialogOperation(dialogTitle).clickComponent(new robotCross.TextMatcher(ControlsProperties.getString("String_ExportPath")));
		new DialogOperation(dialogTitle).clickComponent(new NameMatcher("FileChooserControl_button"));
		new JFileChooserOperation().chooseDir(exportPath, true);//选择导出目录，不存在就新建
		Operation.robot.delay(500);
		new DialogOperation(dialogTitle).clickComponent(new TipMatcher(CoreProperties.getString("String_OK")));
		Operation.robot.delay(1000);
		new DialogOperation("数据导出").clickComponent(new NameMatcher(("DataExportDialog_buttonExport")));
		new CommonOperation().waitForProgressDispose(30000);

		//文件比较
		System.out.println("Result File compare:" + FileComparer.compare(resultFiles));
	}

	//===========modeling==========

	/**
	 * AutoCAD
	 */
	@Test
	public void testImportAutoCAD() throws Exception {
		//新建数据源
		String[] filePaths = {DataUtil.testDataPath + "ImportData/AutoCAD/给水管道.dxf", DataUtil.testDataPath + "ImportData/AutoCAD/shuilifang.dwg"};
		String resultDsPath = DataUtil.resultPath_actual + "ImportData/AutoCAD/testImportAutoCAD.udb";
		String expDsPath = DataUtil.resultPath_exp + "ImportData/AutoCAD/testImportAutoCAD.udb";
		String titleDXF = "导入.DXF";
		String titleDWG = "导入.DWG";

		//新建文件数据源
		Operation.helper = new AWTFixtureHelper();
		robot = Operation.helper.getRobot();
		CommonOperation.createUDB(resultDsPath);
		//打开建模
		ModelOperation.startModeling();
		//拖拽节点到画布
		ModelTreeOperation modelTreeOperation = new ModelTreeOperation();
		modelTreeOperation.selectTreeNode("数据导入", "AutoCAD", titleDXF);
		ModelWindowOperation modelWindowOperation = new ModelWindowOperation();
		modelWindowOperation.dragToCanvasPoint(new Point(0, 50));
		modelTreeOperation.selectTreeNode("数据导入", "AutoCAD", titleDWG);
		modelWindowOperation.dragToCanvasPoint(new Point(0, -50));
		//选中节点，设置参数
		modelWindowOperation.clickProcessGraph(titleDXF);
		new Operation(modelWindowOperation.getContainer()).clickRightButtonMenuItem("参数设置");
		DockbarOperation dockbarOperation = new DockbarOperation("参数设置");
		dockbarOperation.clickComponent(new NameMatcher("FileChooserControl_button"));
		new JFileChooserOperation().chooseFile(filePaths[0]);
		modelWindowOperation.clickProcessGraph(titleDWG);
		dockbarOperation.clickComponent(new NameMatcher("FileChooserControl_button"));
//		dockbarOperation.setComboBoxSelectedItem(new NameMatcher(ProcessProperties.getString("String_Label_DatasetType")), ControlsProperties.getString("String_SampleDataset"));
		new JFileChooserOperation().chooseFile(filePaths[1]);
		//点击执行
		ModelOperation.runWorkFlow();
		//等待进度条 2mins
		int i = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(2));
		if (i != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}
		//结果对比
		Datasource resultDatasource = CommonOperation.getDatasource(0);
		Datasource expDatasource = CommonOperation.openDatasource(expDsPath);
		compareOperation.compareDataset(expDatasource, resultDatasource);
	}

	/**
	 * ArcGIS 有缺陷，导入e00节点没刷新；导入dem失败--dem后缀有好几种，可能类型没对。
	 */
	@Test
	public void testImportArcGIS() throws Exception {
		//新建数据源
		String[] filePaths = {
				DataUtil.testDataPath + "ImportData/ArcGIS/BaseMap_R.shp",
				DataUtil.testDataPath + "ImportData/ArcGIS/anumike-5.grd",
				DataUtil.testDataPath + "ImportData/ArcGIS/img_grd.txt",
				DataUtil.testDataPath + "ImportData/ArcGIS/rail.e00",
				DataUtil.testDataPath + "ImportData/ArcGIS/ArcGISDEM.dem",
				DataUtil.testDataPath + "ImportData/ArcGIS/BaseMap_R.dbf"};
		String resultDsPath = DataUtil.resultPath_actual + "ImportData/ArcGIS/testImportArcGIS.udb";
		String expDsPath = DataUtil.resultPath_exp + "ImportData/ArcGIS/testImportArcGIS.udb";
		String[] titles = {"导入.SHP", "导入.GRD", "导入.TXT", "导入.E00", "导入.DEM", "导入.DBF"};

		//新建文件数据源
		CommonOperation.createUDB(resultDsPath);
		//打开建模
		ModelOperation.startModeling();
		//拖拽节点到画布
		ModelTreeOperation modelTreeOperation = new ModelTreeOperation();
		ModelWindowOperation modelWindowOperation = new ModelWindowOperation();
		modelTreeOperation.selectTreeNode("数据导入", "ArcGIS", titles[0]);
		modelWindowOperation.dragToCanvasPoint(new Point(0, -200));
		modelTreeOperation.selectTreeNode("数据导入", "ArcGIS", titles[1]);
		modelWindowOperation.dragToCanvasPoint(new Point(0, -150));
		modelTreeOperation.selectTreeNode("数据导入", "ArcGIS", titles[2]);
		modelWindowOperation.dragToCanvasPoint(new Point(0, -100));
		modelTreeOperation.selectTreeNode("数据导入", "ArcGIS", titles[3]);
		modelWindowOperation.dragToCanvasPoint(new Point(0, -50));
		modelTreeOperation.selectTreeNode("数据导入", "ArcGIS", titles[4]);
		modelWindowOperation.dragToCanvasPoint(new Point(0, 0));
		modelTreeOperation.selectTreeNode("数据导入", "ArcGIS", titles[5]);
		modelWindowOperation.dragToCanvasPoint(new Point(0, 50));
		//选中节点，设置参数
		Operation operation = new Operation(modelWindowOperation.getContainer());
		modelWindowOperation.clickProcessGraph(titles[0]);
		operation.clickRightButtonMenuItem("参数设置");
		DockbarOperation dockbarOperation = new DockbarOperation("参数设置");
		dockbarOperation.clickComponent(new NameMatcher("FileChooserControl_button"));
		new JFileChooserOperation().chooseFile(filePaths[0]);
		for (int i = 1; i < 6; i++) {
			modelWindowOperation.clickProcessGraph(titles[i]);
			dockbarOperation.clickComponent(new NameMatcher("FileChooserControl_button"));
			new JFileChooserOperation().chooseFile(filePaths[i]);
		}
		//点击执行
		ModelOperation.runWorkFlow();
		//等待进度条 3mins
		int i = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(3));
		if (i != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}
		//结果对比
		Datasource resultDatasource = CommonOperation.getDatasource(0);
		Datasource expDatasource = CommonOperation.openDatasource(expDsPath);
		compareOperation.compareDataset(expDatasource, resultDatasource);
	}

	/**
	 * MapInfo_tab&mif 有缺陷：导入之后节点没刷新，导入为CAD也会到为简单数据集
	 */
	@Test
	public void testImportMapInfo_TabAndMif() throws Exception {
		//新建数据源
		String[] filePaths = {
				DataUtil.testDataPath + "ImportData/MapInfo/world/world.TAB",
				DataUtil.testDataPath + "ImportData/MapInfo/all.MIF"};
		String resultDsPath = DataUtil.resultPath_actual + "ImportData/MapInfo/testImportTabAndMif.udb";
		String expDsPath = DataUtil.resultPath_exp + "ImportData/MapInfo/testImportTabAndMif.udb";
		String[] titles = {"导入.TAB", "导入.MIF"};

		//新建文件数据源
		CommonOperation.createUDB(resultDsPath);
		//打开建模
		ModelOperation.startModeling();
		//拖拽节点到画布
		ModelTreeOperation modelTreeOperation = new ModelTreeOperation();
		ModelWindowOperation modelWindowOperation = new ModelWindowOperation();
		modelTreeOperation.selectTreeNode("数据导入", "MapInfo", titles[0]);
		modelWindowOperation.dragToCanvasPoint(new Point(0, -50));
		modelTreeOperation.selectTreeNode("数据导入", "MapInfo", titles[1]);
		modelWindowOperation.dragToCanvasPoint(new Point(0, 0));
		//选中节点，设置参数
		Operation operation = new Operation(modelWindowOperation.getContainer());
		modelWindowOperation.clickProcessGraph(titles[0]);
		operation.clickRightButtonMenuItem("参数设置");
		DockbarOperation dockbarOperation = new DockbarOperation("参数设置");
		dockbarOperation.clickComponent(new NameMatcher("FileChooserControl_button"));
		new JFileChooserOperation().chooseFile(filePaths[0]);
		modelWindowOperation.clickProcessGraph(titles[1]);
		dockbarOperation.clickComponent(new NameMatcher("FileChooserControl_button"));
		new JFileChooserOperation().chooseFile(filePaths[1]);
		//点击执行
		ModelOperation.runWorkFlow();
		//等待进度条 1min
		int i = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(3));
		if (i != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}
		//重新设置为导入简单数据集，再次导入
		modelWindowOperation.clickProcessGraph(titles[0]);
		operation.clickRightButtonMenuItem("参数设置");
		dockbarOperation.setComboBoxSelectedItem(new NameMatcher(ProcessProperties.getString("String_Label_DatasetType")), ControlsProperties.getString("String_SampleDataset"));
		modelWindowOperation.clickProcessGraph(titles[1]);
		dockbarOperation.setComboBoxSelectedItem(new NameMatcher(ProcessProperties.getString("String_Label_DatasetType")), ControlsProperties.getString("String_SampleDataset"));
		//点击执行
		ModelOperation.runWorkFlow();
		//等待进度条 1min
		i = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(3));
		if (i != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}
		//结果对比
		Datasource resultDatasource = CommonOperation.getDatasource(0);
		Datasource expDatasource = CommonOperation.openDatasource(expDsPath);
		compareOperation.compareDataset(expDatasource, resultDatasource);
	}

	/**
	 * MapInfo_Wor 结果包含地图节点
	 */
	@Test
	public void testImportMapInfo_Wor() throws Exception {
		//新建数据源
		String filePath = DataUtil.testDataPath + "ImportData/MapInfo/world/world.Wor";
		String resultDsPath = DataUtil.resultPath_actual + "ImportData/MapInfo/testImportWor.udb";
		String expDsPath = DataUtil.resultPath_exp + "ImportData/MapInfo/testImportWor.udb";
		String title = "导入.WOR";
		String[] mapNames = {"Map_1", "Map_2", "Map_3"};
		String templateDir_exp = DataUtil.resultPath_exp + "ImportData/MapInfo/WorMapTemplates/";
		String templateDir_actual = DataUtil.resultPath_actual + "ImportData/MapInfo/WorMapTemplates/";

		//新建文件数据源
		CommonOperation.createUDB(resultDsPath);
		//打开建模
		ModelOperation.startModeling();
		//拖拽节点到画布
		ModelTreeOperation modelTreeOperation = new ModelTreeOperation();
		ModelWindowOperation modelWindowOperation = new ModelWindowOperation();
		modelTreeOperation.selectTreeNode("数据导入", "MapInfo", title);
		modelWindowOperation.dragToCanvasPoint(new Point(0, 0));
		//选中节点，设置参数
		Operation operation = new Operation(modelWindowOperation.getContainer());
		modelWindowOperation.clickProcessGraph(title);
		operation.clickRightButtonMenuItem("参数设置");
		DockbarOperation dockbarOperation = new DockbarOperation("参数设置");
		dockbarOperation.clickComponent(new NameMatcher("FileChooserControl_button"));
		new JFileChooserOperation().chooseFile(filePath);
		//点击执行
		ModelOperation.runWorkFlow();
		//等待进度条 2min
		int i = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(2));
		if (i != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}
		//结果对比
		Datasource resultDatasource = CommonOperation.getDatasource(0);
		Datasource expDatasource = CommonOperation.openDatasource(expDsPath);
		compareOperation.compareDataset(expDatasource, resultDatasource);
		//结果地图导出为模板对比
		if (MapOperation.getMapsCount() != 3) {
			errorCollector.addError(new Throwable(String.format("Wrong maps count! expected: %d, actual: %d", 3, MapOperation.getMapsCount())));
		}
		for (String mapName : mapNames) {
			MapOperation.exportMapTemplate(mapName, templateDir_actual + mapName + ".xml");
		}
		for (String mapName : mapNames) {
			boolean compareResult = false;
			try {
				compareResult = FileComparer.compare(templateDir_exp + mapName + ".xml", templateDir_actual + mapName + ".xml");
			} catch (Exception e) {
				errorCollector.addError(e);
			}
			if (!compareResult) {
				errorCollector.addError(new Throwable(String.format("Files not the same:%s, %s", templateDir_exp + mapName + ".xml", templateDir_actual + mapName + ".xml")));
			}
		}
	}

	/**
	 * MapGIS
	 */
	@Test
	public void testImportMapGIS() throws Exception {
		//新建数据源
		String[] filePaths = {
				DataUtil.testDataPath + "ImportData/MapGIS/开平规划.wat",
				DataUtil.testDataPath + "ImportData/MapGIS/net.wan",
				DataUtil.testDataPath + "ImportData/MapGIS/testL.wal",
				DataUtil.testDataPath + "ImportData/MapGIS/居民地.wap"};
		String resultDsPath = DataUtil.resultPath_actual + "ImportData/MapGIS/testImportMapGIS.udb";
		String expDsPath = DataUtil.resultPath_exp + "ImportData/MapGIS/testImportMapGIS.udb";
		String[] titles = {"导入.WAT", "导入.WAN", "导入.WAL", "导入.WAP"};

		//新建文件数据源
		CommonOperation.createUDB(resultDsPath);
		//打开建模
		ModelOperation.startModeling();
		//拖拽节点到画布
		ModelTreeOperation modelTreeOperation = new ModelTreeOperation();
		ModelWindowOperation modelWindowOperation = new ModelWindowOperation();
		modelTreeOperation.selectTreeNode("数据导入", "MapGIS", titles[0]);
		modelWindowOperation.dragToCanvasPoint(new Point(0, -100));
		modelTreeOperation.selectTreeNode("数据导入", "MapGIS", titles[1]);
		modelWindowOperation.dragToCanvasPoint(new Point(0, -50));
		modelTreeOperation.selectTreeNode("数据导入", "MapGIS", titles[2]);
		modelWindowOperation.dragToCanvasPoint(new Point(0, 0));
		modelTreeOperation.selectTreeNode("数据导入", "MapGIS", titles[3]);
		modelWindowOperation.dragToCanvasPoint(new Point(0, 50));
		//选中节点，设置参数
		Operation operation = new Operation(modelWindowOperation.getContainer());
		modelWindowOperation.clickProcessGraph(titles[0]);
		operation.clickRightButtonMenuItem("参数设置");
		DockbarOperation dockbarOperation = new DockbarOperation("参数设置");
		dockbarOperation.clickComponent(new NameMatcher("FileChooserControl_button"));
		new JFileChooserOperation().chooseFile(filePaths[0]);
		for (int i = 1; i < 4; i++) {
			modelWindowOperation.clickProcessGraph(titles[i]);
			dockbarOperation.clickComponent(new NameMatcher("FileChooserControl_button"));
			new JFileChooserOperation().chooseFile(filePaths[i]);
		}
		//点击执行
		ModelOperation.runWorkFlow();
		//等待进度条 3mins
		int state = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(3));
		if (state != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}
		//重新设置为导入简单数据集，再次导入
		modelWindowOperation.clickProcessGraph(titles[0]);
		operation.clickRightButtonMenuItem("参数设置");
		dockbarOperation.setComboBoxSelectedItem(new NameMatcher(ProcessProperties.getString("String_Label_DatasetType")), ControlsProperties.getString("String_SampleDataset"));
		for (int i = 1; i < 4; i++) {
			modelWindowOperation.clickProcessGraph(titles[i]);
			dockbarOperation.setComboBoxSelectedItem(new NameMatcher(ProcessProperties.getString("String_Label_DatasetType")), ControlsProperties.getString("String_SampleDataset"));
		}
		//点击执行
		ModelOperation.runWorkFlow();
		//等待进度条 1min
		state = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(3));
		if (state != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}
		//结果对比
		Datasource resultDatasource = CommonOperation.getDatasource(0);
		Datasource expDatasource = CommonOperation.openDatasource(expDsPath);
		compareOperation.compareDataset(expDatasource, resultDatasource);
	}

	/**
	 * CSV 2018.1 导
	 * fixed 结果中宽字符长度比之前长了10，比对不过，待与组件确认后更新exp数据
	 */
	@Test
	public void testImportCSV() throws Exception {
		//操作覆盖：用XY坐标导入点、用WKT导入面、导入纯属性数据
		//新建数据源
		String[] filePaths = {
				DataUtil.testDataPath + "ImportData/CSV/ChinaPOI.csv",
				DataUtil.testDataPath + "ImportData/CSV/BaseMap_R.csv"};
		String resultDsPath = DataUtil.resultPath_actual + "ImportData/CSV/testImportCSV.udb";
		String expDsPath = DataUtil.resultPath_exp + "ImportData/CSV/testImportCSV.udb";
		String title = "导入.CSV";

		//新建文件数据源
		CommonOperation.createUDB(resultDsPath);
		//打开建模
		ModelOperation.startModeling();

		//--------导入点---------
		//拖拽节点到画布
		ModelTreeOperation modelTreeOperation = new ModelTreeOperation();
		ModelWindowOperation modelWindowOperation = new ModelWindowOperation();
		modelTreeOperation.selectTreeNode("数据导入", "电子表格", title);
		modelWindowOperation.dragToCanvasPoint(new Point(0, -50));
		//选中节点，设置参数
		Operation operation = new Operation(modelWindowOperation.getContainer());
		modelWindowOperation.clickProcessGraph(title);
		operation.clickRightButtonMenuItem("参数设置");
		DockbarOperation dockbarOperation = new DockbarOperation("参数设置");
		dockbarOperation.clickComponent(new NameMatcher("FileChooserControl_button"));
		new JFileChooserOperation().chooseFile(filePaths[0]);
		//set charset
		dockbarOperation.setComboBoxSelectedItem(new NameMatcher(ControlsProperties.getString("String_LabelCharset")), CharsetProperties.getString(CharsetProperties.GB18030));
		//导入空间数据，设置坐标字段
		dockbarOperation.clickComponent(new NameMatcher(CoreProperties.getString("String_ImportIndexData")));
		dockbarOperation.clickComponent(new TextMatcher(CoreProperties.getString("String_XYField")));
		dockbarOperation.setComboBoxSelectedItem(new NameMatcher(CoreProperties.getString("string_longitude")), "x");
		dockbarOperation.setComboBoxSelectedItem(new NameMatcher(CoreProperties.getString("string_latitude")), "y");
		//点击执行
		ModelOperation.runWorkFlow();
		//等待进度条 2min
		int i = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(2));
		if (i != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}

		//--------导入上一个数据为属性数据，导入面---------
		DockbarOperation.setVisible(ProcessProperties.getString("String_ToolBox"));
		modelTreeOperation.selectTreeNode("数据导入", "电子表格", title);
		modelWindowOperation.dragToCanvasPoint(new Point(0, 0));
		//导入属性
		modelWindowOperation.clickProcessGraph(title);
		operation.clickRightButtonMenuItem("参数设置");
		dockbarOperation.clickComponent(new NameMatcher(CoreProperties.getString("String_ImportIndexData")));
		//添加节点，导入面
		modelWindowOperation.clickProcessGraph(title + "(1)");
		dockbarOperation.clickComponent(new NameMatcher("FileChooserControl_button"));
		new JFileChooserOperation().chooseFile(filePaths[1]);
		//set charset
		//导入空间数据，设置坐标字段
		dockbarOperation.clickComponent(new NameMatcher(CoreProperties.getString("String_ImportIndexData")));
		//点击执行
		ModelOperation.runWorkFlow();
		//等待进度条 2min
		i = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(2));
		if (i != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}
		//结果对比
		Datasource resultDatasource = CommonOperation.getDatasource(0);
		Datasource expDatasource = CommonOperation.openDatasource(expDsPath);
		compareOperation.compareDataset(expDatasource, resultDatasource);
	}

	/**
	 * Excel
	 * fixme 2018.1 sheet.xlsx 中包含两张表，第二个导入时，SmID字段导入为 Field_SmID_1了，应该是 Field_SmID，对比不过
	 */
	@Test
	public void testImportExcel() throws Exception {
		//新建数据源
		String filePath = DataUtil.testDataPath + "ImportData/Excel/sheet.xlsx";
		String resultDsPath = DataUtil.resultPath_actual + "ImportData/Excel/testImportExcel.udb";
		String expDsPath = DataUtil.resultPath_exp + "ImportData/Excel/testImportExcel.udb";
		String title = "导入Excel";

		//新建文件数据源
		CommonOperation.createUDB(resultDsPath);
		//打开建模
		ModelOperation.startModeling();
		//拖拽节点到画布
		ModelTreeOperation modelTreeOperation = new ModelTreeOperation();
		ModelWindowOperation modelWindowOperation = new ModelWindowOperation();
		modelTreeOperation.selectTreeNode("数据导入", "电子表格", title);
		modelWindowOperation.dragToCanvasPoint(new Point(0, 0));
		//选中节点，设置参数
		Operation operation = new Operation(modelWindowOperation.getContainer());
		modelWindowOperation.clickProcessGraph(title);
		operation.clickRightButtonMenuItem("参数设置");
		DockbarOperation dockbarOperation = new DockbarOperation("参数设置");
		dockbarOperation.clickComponent(new NameMatcher("FileChooserControl_button"));
		new JFileChooserOperation().chooseFile(filePath);
		//点击执行
		ModelOperation.runWorkFlow();
		//等待进度条 2min
		int i = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(2));
		if (i != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}
		//结果对比
		Datasource resultDatasource = CommonOperation.getDatasource(0);
		Datasource expDatasource = CommonOperation.openDatasource(expDsPath);
		compareOperation.compareDataset(expDatasource, resultDatasource);
	}

	/**
	 * IMG_TIF_SID_ECW
	 */
	@Test
	public void testImportIMG_TIF_SID_ECW() throws Exception {
		String[] filePaths = {
				DataUtil.testDataPath + "ImportData/images/JingjinImage.img",
				DataUtil.testDataPath + "ImportData/images/JingjinImage.tif",
				DataUtil.testDataPath + "ImportData/images/Vienna.sid",
				DataUtil.testDataPath + "ImportData/images/shiqu.ecw"};
		String resultDsPath = DataUtil.resultPath_actual + "ImportData/images/testImportIMG_TIF_SID_ECW.udb";
		String expDsPath = DataUtil.resultPath_exp + "ImportData/images/testImportIMG_TIF_SID_ECW.udb";
		String[] titles = {"导入.IMG", "导入.TIF", "导入.SID", "导入.ECW"};

		//新建文件数据源
		CommonOperation.createUDB(resultDsPath);
		//打开建模
		ModelOperation.startModeling();
		//拖拽节点到画布
		ModelTreeOperation modelTreeOperation = new ModelTreeOperation();
		ModelWindowOperation modelWindowOperation = new ModelWindowOperation();
		modelTreeOperation.selectTreeNode("数据导入", "影像位图文件", titles[0]);
		modelWindowOperation.dragToCanvasPoint(new Point(0, -150));
		modelTreeOperation.selectTreeNode("数据导入", "影像位图文件", titles[1]);
		modelWindowOperation.dragToCanvasPoint(new Point(0, -100));
		modelTreeOperation.selectTreeNode("数据导入", "影像位图文件", titles[2]);
		modelWindowOperation.dragToCanvasPoint(new Point(0, -50));
		modelTreeOperation.selectTreeNode("数据导入", "影像位图文件", titles[3]);
		modelWindowOperation.dragToCanvasPoint(new Point(0, 0));
		//选中节点，设置参数
		Operation operation = new Operation(modelWindowOperation.getContainer());
		modelWindowOperation.clickProcessGraph(titles[0]);
		operation.clickRightButtonMenuItem("参数设置");
		DockbarOperation dockbarOperation = new DockbarOperation("参数设置");
		for (int i = 0; i < titles.length; i++) {
			modelWindowOperation.clickProcessGraph(titles[i]);
			dockbarOperation.clickComponent(new NameMatcher("FileChooserControl_button"));
			new JFileChooserOperation().chooseFile(filePaths[i]);
			dockbarOperation.setComboBoxSelectedItem(new NameMatcher(ControlsProperties.getString("string_label_lblSaveImport")), CoreProperties.getString("String_MultiBand_Composite"));
		}
		ModelOperation.runWorkFlow();
		int state = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(3));
		if (state != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}
		//导入为多波段
		modelWindowOperation.clickProcessGraph(titles[0]);
		operation.clickRightButtonMenuItem("参数设置");
		for (int i = 0; i < titles.length; i++) {
			modelWindowOperation.clickProcessGraph(titles[i]);
			dockbarOperation.setComboBoxSelectedItem(new NameMatcher(ControlsProperties.getString("string_label_lblSaveImport")), CoreProperties.getString("String_MultiBand_MultiBand"));
		}
		ModelOperation.runWorkFlow();
		state = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(3));
		if (state != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}
		//导入为多个单波段
		modelWindowOperation.clickProcessGraph(titles[0]);
		operation.clickRightButtonMenuItem("参数设置");
		for (int i = 0; i < titles.length; i++) {
			modelWindowOperation.clickProcessGraph(titles[i]);
			dockbarOperation.setComboBoxSelectedItem(new NameMatcher(ControlsProperties.getString("string_label_lblSaveImport")), CoreProperties.getString("String_MultiBand_SingleBand"));
		}
		ModelOperation.runWorkFlow();
		state = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(3));
		if (state != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}
		//导入为多个单波段、栅格
		modelWindowOperation.clickProcessGraph(titles[0]);
		operation.clickRightButtonMenuItem("参数设置");
		for (int i = 0; i < titles.length; i++) {
			modelWindowOperation.clickProcessGraph(titles[i]);
			dockbarOperation.setComboBoxSelectedItem(new NameMatcher(ProcessProperties.getString("String_Label_DatasetType")), CoreProperties.getString("String_DatasetType_Grid"));
		}
		ModelOperation.runWorkFlow();
		state = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(3));
		if (state != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}
		//导入为合成波段、栅格
		modelWindowOperation.clickProcessGraph(titles[3]);
		operation.clickRightButtonMenuItem("参数设置");
		dockbarOperation.setComboBoxSelectedItem(new NameMatcher(ControlsProperties.getString("string_label_lblSaveImport")), CoreProperties.getString("String_MultiBand_Composite"));
		ModelOperation.runWorkFlow();
		state = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(3));
		if (state != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}
		//// FIXME: 2017/11/15 先不上传数据了，执行结果1.5G。待实现方案：导出数据源描述文件
	/*	Datasource resultDatasource = CommonOperation.getDatasource(0);
		Datasource expDatasource = CommonOperation.openDatasource(expDsPath);
		compareOperation.compareDataset(expDatasource, resultDatasource);*/
	}

	/**
	 * BMP_PNG_GIF_JPG
	 * fixed 2018.1.12  图片默认编码格式变了，现在的是PNG，和.net一致，需要替换249上的exp，否则对比不过
	 */
	@Test
	public void testImportBMP_PNG_GIF_JPG() throws Exception {
		String[] filePaths = {
				DataUtil.testDataPath + "ImportData/images/dem_32.bmp",
				DataUtil.testDataPath + "ImportData/images/mountain.png",
				DataUtil.testDataPath + "ImportData/images/world500.GIF",
				DataUtil.testDataPath + "ImportData/images/Ba_8.jpg"};
		String resultDsPath = DataUtil.resultPath_actual + "ImportData/images/testImportBMP_PNG_GIF_JPG.udb";
		String expDsPath = DataUtil.resultPath_exp + "ImportData/images/testImportBMP_PNG_GIF_JPG.udb";
		String[] titles = {"导入.BMP", "导入.PNG", "导入.GIF", "导入.JPG"};

		//新建文件数据源
		CommonOperation.createUDB(resultDsPath);
		//打开建模
		ModelOperation.startModeling();
		//拖拽节点到画布
		ModelTreeOperation modelTreeOperation = new ModelTreeOperation();
		ModelWindowOperation modelWindowOperation = new ModelWindowOperation();
		modelTreeOperation.selectTreeNode("数据导入", "影像位图文件", titles[0]);
		modelWindowOperation.dragToCanvasPoint(new Point(0, -200));
		modelTreeOperation.selectTreeNode("数据导入", "影像位图文件", titles[1]);
		modelWindowOperation.dragToCanvasPoint(new Point(0, -150));
		modelTreeOperation.selectTreeNode("数据导入", "影像位图文件", titles[2]);
		modelWindowOperation.dragToCanvasPoint(new Point(0, -100));
		modelTreeOperation.selectTreeNode("数据导入", "影像位图文件", titles[3]);
		modelWindowOperation.dragToCanvasPoint(new Point(0, -50));
		//选中节点，设置参数
		Operation operation = new Operation(modelWindowOperation.getContainer());
		modelWindowOperation.clickProcessGraph(titles[0]);
		operation.clickRightButtonMenuItem("参数设置");
		DockbarOperation dockbarOperation = new DockbarOperation("参数设置");
		for (int i = 0; i < 4; i++) {
			modelWindowOperation.clickProcessGraph(titles[i]);
			dockbarOperation.clickComponent(new NameMatcher("FileChooserControl_button"));
			new JFileChooserOperation().chooseFile(filePaths[i]);
			//创建影像金字塔
			dockbarOperation.clickComponent(new NameMatcher(ControlsProperties.getString("String_Form_BuildDatasetPyramid")));
		}
		ModelOperation.runWorkFlow();
		int state = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(3));
		if (state != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}

		//导入为栅格
		modelWindowOperation.clickProcessGraph(titles[0]);
		for (int i = 0; i < 4; i++) {
			modelWindowOperation.clickProcessGraph(titles[i]);
			dockbarOperation.setComboBoxSelectedItem(new NameMatcher(ProcessProperties.getString("String_Label_DatasetType")), CoreProperties.getString("String_DatasetType_Grid"));
		}
		ModelOperation.runWorkFlow();
		state = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(3));
		if (state != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}

		//结果对比
		Datasource resultDatasource = CommonOperation.getDatasource(0);
		Datasource expDatasource = CommonOperation.openDatasource(expDsPath);
		compareOperation.compareDataset(expDatasource, resultDatasource);
	}

	/**
	 * JP2
	 * fixed 2018.1.12 强制覆盖没有覆盖掉，数据集未打开--功能缺陷：导入数据不需要计算和设置数据集名称，组件会设置的
	 */
	@Test
	public void testImportJP2() throws Exception {
		//新建数据源
		String filePath = DataUtil.testDataPath + "ImportData/images/TM_7B.jp2";
		String resultDsPath = DataUtil.resultPath_actual + "ImportData/images/testImportJP2.udb";
		String expDsPath = DataUtil.resultPath_exp + "ImportData/images/testImportJP2.udb";
		String title = "导入.JP2";

		//新建文件数据源
		CommonOperation.createUDB(resultDsPath);
		//打开建模
		ModelOperation.startModeling();
		//拖拽节点到画布
		ModelTreeOperation modelTreeOperation = new ModelTreeOperation();
		ModelWindowOperation modelWindowOperation = new ModelWindowOperation();
		modelTreeOperation.selectTreeNode("数据导入", "影像位图文件", title);
		modelWindowOperation.dragToCanvasPoint(new Point(-50, 0));
		//选中节点，设置参数
		Operation operation = new Operation(modelWindowOperation.getContainer());
		modelWindowOperation.clickProcessGraph(title);
		operation.clickRightButtonMenuItem("参数设置");
		DockbarOperation dockbarOperation = new DockbarOperation("参数设置");
		dockbarOperation.clickComponent(new NameMatcher("FileChooserControl_button"));
		new JFileChooserOperation().chooseFile(filePath);
		//设置数据集名称
		dockbarOperation.setTextComponentValue(new NameMatcher(CoreProperties.getString("String_Label_Dataset")), "testJP2");
		ModelOperation.runWorkFlow();
		int i = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(2));
		if (i != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}
		//再次导入覆盖
		modelWindowOperation.clickProcessGraph(title);
		operation.clickRightButtonMenuItem("参数设置");
		dockbarOperation.setComboBoxSelectedItem(new NameMatcher(ControlsProperties.getString("string_label_lblImportType")), ControlsProperties.getString("String_FormImport_OverWrite"));
		ModelOperation.runWorkFlow();
		i = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(2));
		if (i != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}
		//导入为栅格
		modelWindowOperation.clickProcessGraph(title);
		operation.clickRightButtonMenuItem("参数设置");
		dockbarOperation.setComboBoxSelectedItem(new NameMatcher(ProcessProperties.getString("String_Label_DatasetType")), CoreProperties.getString("String_DatasetType_Grid"));
		dockbarOperation.setComboBoxSelectedItem(new NameMatcher(ControlsProperties.getString("string_label_lblImportType")), CoreProperties.getString("String_None"));
		ModelOperation.runWorkFlow();
		i = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(2));
		if (i != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}

		//结果对比
		Datasource resultDatasource = CommonOperation.getDatasource(0);
		Datasource expDatasource = CommonOperation.openDatasource(expDsPath);
		compareOperation.compareDataset(expDatasource, resultDatasource);
	}

	/**
	 * KML_KMZ
	 * fixed 2018.1.12 生成的数据集默认名称变化。hangzhouCity导入为简单数据集，之前的结果是 hangzhouCityT hangzhouCityT_1,现在是 hangzhouCity_1T
	 */
	@Test
	public void testImportKML_KMZ() throws Exception {
		String[] filePaths = {
				DataUtil.testDataPath + "ImportData/GoogleKML/hangzhouCity.kml",
				DataUtil.testDataPath + "ImportData/GoogleKML/hangzhouCity1.kmz"};
		String resultDsPath = DataUtil.resultPath_actual + "ImportData/GoogleKML/testImportKML_KMZ.udb";
		String expDsPath = DataUtil.resultPath_exp + "ImportData/GoogleKML/testImportKML_KMZ.udb";
		String[] titles = {"导入.KML", "导入.KMZ"};

		//新建文件数据源
		CommonOperation.createUDB(resultDsPath);
		//打开建模
		ModelOperation.startModeling();
		//拖拽节点到画布
		ModelTreeOperation modelTreeOperation = new ModelTreeOperation();
		ModelWindowOperation modelWindowOperation = new ModelWindowOperation();
		modelTreeOperation.selectTreeNode("数据导入", "谷歌KML", titles[0]);
		modelWindowOperation.dragToCanvasPoint(new Point(0, -100));
		modelTreeOperation.selectTreeNode("数据导入", "谷歌KML", titles[1]);
		modelWindowOperation.dragToCanvasPoint(new Point(0, -50));
		//选中节点，设置参数
		Operation operation = new Operation(modelWindowOperation.getContainer());
		modelWindowOperation.clickProcessGraph(titles[0]);
		operation.clickRightButtonMenuItem("参数设置");
		DockbarOperation dockbarOperation = new DockbarOperation("参数设置");
		for (int i = 0; i < 2; i++) {
			modelWindowOperation.clickProcessGraph(titles[i]);
			dockbarOperation.clickComponent(new NameMatcher("FileChooserControl_button"));
			new JFileChooserOperation().chooseFile(filePaths[i]);
		}
		ModelOperation.runWorkFlow();
		int state = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(1));
		if (state != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}

		//导入简单数据集
		modelWindowOperation.clickProcessGraph(titles[0]);
		for (int i = 0; i < 2; i++) {
			modelWindowOperation.clickProcessGraph(titles[i]);
			//导入为简单数据集
			dockbarOperation.setComboBoxSelectedItem(new NameMatcher(ProcessProperties.getString("String_Label_DatasetType")), ControlsProperties.getString("String_SampleDataset"));
			//取消导入不可见对象
			dockbarOperation.clickComponent(new NameMatcher(CoreProperties.getString("String_ImportUnvisibleObject")));
		}
		ModelOperation.runWorkFlow();
		state = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(1));
		if (state != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}

		//结果对比
		Datasource resultDatasource = CommonOperation.getDatasource(0);
		Datasource expDatasource = CommonOperation.openDatasource(expDsPath);
		compareOperation.compareDataset(expDatasource, resultDatasource);
	}

	/**
	 * LIDAR
	 */
	@Test
	public void testImportLIDAR() throws Exception {
		//新建数据源
		String filePath = DataUtil.testDataPath + "ImportData/LIDAR/points8w.txt";
		String resultDsPath = DataUtil.resultPath_actual + "ImportData/LIDAR/testImportLIDAR.udb";
		String expDsPath = DataUtil.resultPath_exp + "ImportData/LIDAR/testImportLIDAR.udb";
		String title = "导入.TXT";

		//新建文件数据源
		CommonOperation.createUDB(resultDsPath);
		//打开建模
		ModelOperation.startModeling();
		//拖拽节点到画布
		ModelTreeOperation modelTreeOperation = new ModelTreeOperation();
		ModelWindowOperation modelWindowOperation = new ModelWindowOperation();
		modelTreeOperation.selectTreeNode("数据导入", "LIDAR文件", title);
		modelWindowOperation.dragToCanvasPoint(new Point(-50, 0));
		//选中节点，设置参数
		Operation operation = new Operation(modelWindowOperation.getContainer());
		modelWindowOperation.clickProcessGraph(title);
		operation.clickRightButtonMenuItem("参数设置");
		DockbarOperation dockbarOperation = new DockbarOperation("参数设置");
		dockbarOperation.clickComponent(new NameMatcher("FileChooserControl_button"));
		new JFileChooserOperation().chooseFile(filePath);
		//设置数据集名称，导入二维数据集
		dockbarOperation.setTextComponentValue(new NameMatcher(CoreProperties.getString("String_Label_Dataset")), "testLIDAR");
		dockbarOperation.setComboBoxSelectedItem(new NameMatcher(ProcessProperties.getString("String_Label_DatasetType")), ControlsProperties.getString("String_datasetType2D"));
		ModelOperation.runWorkFlow();
		int i = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(2));
		if (i != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}
		//导入为3D
		modelWindowOperation.clickProcessGraph(title);
		operation.clickRightButtonMenuItem("参数设置");
		//设置数据集名称，导入二维数据集
		dockbarOperation.setTextComponentValue(new NameMatcher(CoreProperties.getString("String_Label_Dataset")), "testLIDAR3D");
		dockbarOperation.setComboBoxSelectedItem(new NameMatcher(ProcessProperties.getString("String_Label_DatasetType")), ControlsProperties.getString("String_datasetType3D"));
		//忽略属性信息
		dockbarOperation.clickComponent(new NameMatcher(CoreProperties.getString("String_IngoreProperty")));
		ModelOperation.runWorkFlow();
		i = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(2));
		if (i != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}

		//结果对比
		Datasource resultDatasource = CommonOperation.getDatasource(0);
		Datasource expDatasource = CommonOperation.openDatasource(expDsPath);
		compareOperation.compareDataset(expDatasource, resultDatasource);
	}

	/**
	 * GPS
	 */
	@Test
	public void testImportGPS() throws Exception {
		//新建数据源
		String filePath = DataUtil.testDataPath + "ImportData/GPS/Town_P.gpx";
		String resultDsPath = DataUtil.resultPath_actual + "ImportData/GPS/testImportGPS.udb";
		String expDsPath = DataUtil.resultPath_exp + "ImportData/GPS/testImportGPS.udb";
		String title = "导入.GPX";

		//新建文件数据源
		CommonOperation.createUDB(resultDsPath);
		//打开建模
		ModelOperation.startModeling();
		//拖拽节点到画布
		ModelTreeOperation modelTreeOperation = new ModelTreeOperation();
		ModelWindowOperation modelWindowOperation = new ModelWindowOperation();
		modelTreeOperation.selectTreeNode("数据导入", "矢量文件", title);
		modelWindowOperation.dragToCanvasPoint(new Point(-50, 0));
		//选中节点，设置参数
		Operation operation = new Operation(modelWindowOperation.getContainer());
		modelWindowOperation.clickProcessGraph(title);
		operation.clickRightButtonMenuItem("参数设置");
		DockbarOperation dockbarOperation = new DockbarOperation("参数设置");
		dockbarOperation.clickComponent(new NameMatcher("FileChooserControl_button"));
		new JFileChooserOperation().chooseFile(filePath);

		ModelOperation.runWorkFlow();
		int state = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(1));
		if (state != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}

		//结果对比
		Datasource resultDatasource = CommonOperation.getDatasource(0);
		Datasource expDatasource = CommonOperation.openDatasource(expDsPath);
		compareOperation.compareDataset(expDatasource, resultDatasource);
	}

	/**
	 * DGN
	 * fixed 2018.1.12导入数据集命名规则改变，Buildinds_1RZ。原先是不会先加_1（Buildinds存在时）的，直接生成 BuildindsRZ
	 */
	@Test
	public void testImportDGN() throws Exception {
		//新建数据源
		String filePath = DataUtil.testDataPath + "ImportData/DGN/Buildinds.dgn";
		String resultDsPath = DataUtil.resultPath_actual + "ImportData/DGN/testImportDGN.udb";
		String expDsPath = DataUtil.resultPath_exp + "ImportData/DGN/testImportDGN.udb";
		String title = "导入.DGN";

		//新建文件数据源
		CommonOperation.createUDB(resultDsPath);
		//打开建模
		ModelOperation.startModeling();
		//拖拽节点到画布
		ModelTreeOperation modelTreeOperation = new ModelTreeOperation();
		ModelWindowOperation modelWindowOperation = new ModelWindowOperation();
		modelTreeOperation.selectTreeNode("数据导入", "AutoCAD", title);
		modelWindowOperation.dragToCanvasPoint(new Point(-50, 0));
		//选中节点，设置参数
		Operation operation = new Operation(modelWindowOperation.getContainer());
		modelWindowOperation.clickProcessGraph(title);
		operation.clickRightButtonMenuItem("参数设置");
		DockbarOperation dockbarOperation = new DockbarOperation("参数设置");
		dockbarOperation.clickComponent(new NameMatcher("FileChooserControl_button"));
		new JFileChooserOperation().chooseFile(filePath);
		//默认导入：CAD
		ModelOperation.runWorkFlow();
		int state = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(2));
		if (state != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}
		//导入为简单数据集
		modelWindowOperation.clickProcessGraph(title);
		operation.clickRightButtonMenuItem("参数设置");
		dockbarOperation.setComboBoxSelectedItem(new NameMatcher(ProcessProperties.getString("String_Label_DatasetType")), ControlsProperties.getString("String_SampleDataset"));
		ModelOperation.runWorkFlow();
		state = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(3));
		if (state != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}

		//结果对比
		Datasource resultDatasource = CommonOperation.getDatasource(0);
		Datasource expDatasource = CommonOperation.openDatasource(expDsPath);
		compareOperation.compareDataset(expDatasource, resultDatasource);
	}

	/**
	 * GEOJSON fixme:这个后面可以改成迭代器操作
	 */
	@Test
	public void testImportGEOJSON() throws Exception {
		//只导入点线面简单数据集，应该更常用，不导入空数据集
		String[] filePaths = {
				DataUtil.testDataPath + "ImportData/GEOJSON/China_ProCenCity_pt.json",
				DataUtil.testDataPath + "ImportData/GEOJSON/County_L.json",
				DataUtil.testDataPath + "ImportData/GEOJSON/Landuse_R.json"};
		String resultDsPath = DataUtil.resultPath_actual + "ImportData/GEOJSON/testImportGEOJSON.udb";
		String expDsPath = DataUtil.resultPath_exp + "ImportData/GEOJSON/testImportGEOJSON.udb";
		String[] titles = {"导入.GEOJSON", "导入.GEOJSON(1)", "导入.GEOJSON(2)"};

		//新建文件数据源
		CommonOperation.createUDB(resultDsPath);
		//打开建模
		ModelOperation.startModeling();
		//拖拽节点到画布
		ModelTreeOperation modelTreeOperation = new ModelTreeOperation();
		ModelWindowOperation modelWindowOperation = new ModelWindowOperation();
		modelTreeOperation.selectTreeNode("数据导入", "矢量文件", titles[0]);
		modelWindowOperation.dragToCanvasPoint(new Point(0, -150));
		modelTreeOperation.selectTreeNode("数据导入", "矢量文件", titles[0]);
		modelWindowOperation.dragToCanvasPoint(new Point(0, -100));
		modelTreeOperation.selectTreeNode("数据导入", "矢量文件", titles[0]);
		modelWindowOperation.dragToCanvasPoint(new Point(0, -50));
		//选中节点，设置参数
		Operation operation = new Operation(modelWindowOperation.getContainer());
		modelWindowOperation.clickProcessGraph(titles[0]);
		operation.clickRightButtonMenuItem("参数设置");
		DockbarOperation dockbarOperation = new DockbarOperation("参数设置");
		for (int i = 0; i < 3; i++) {
			modelWindowOperation.clickProcessGraph(titles[i]);
			dockbarOperation.clickComponent(new NameMatcher("FileChooserControl_button"));
			new JFileChooserOperation().chooseFile(filePaths[i]);
			//导入为简单数据集
			dockbarOperation.setComboBoxSelectedItem(new NameMatcher(ProcessProperties.getString("String_Label_DatasetType")), ControlsProperties.getString("String_SampleDataset"));
			//UTF8--组件当前的默认导出字符集，即测试数据的字符集，不设置的话中文乱码
			dockbarOperation.setComboBoxSelectedItem(new NameMatcher(ControlsProperties.getString("String_LabelCharset")), CharsetProperties.getString(CharsetProperties.UTF8));
		}
		//点击执行
		ModelOperation.runWorkFlow();
		int i = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(2));
		if (i != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}

		//结果对比
		Datasource resultDatasource = CommonOperation.getDatasource(0);
		Datasource expDatasource = CommonOperation.openDatasource(expDsPath);
		compareOperation.compareDataset(expDatasource, resultDatasource);
	}

	/**
	 * SIMPLEJSON
	 */
	@Test
	public void testImportSIMPLEJSON() throws Exception {
		//只导入点线面和文件夹
		String[] filePaths = {
				DataUtil.testDataPath + "ImportData/SIMPLEJSON/BaseMap_P.json",
				DataUtil.testDataPath + "ImportData/SIMPLEJSON/Neighbor_L.json",
				DataUtil.testDataPath + "ImportData/SIMPLEJSON/BaseMap_R.json",
				DataUtil.testDataPath + "ImportData/SIMPLEJSON/SUM2"};
		String resultDsPath = DataUtil.resultPath_actual + "ImportData/SIMPLEJSON/testImportSIMPLEJSON.udb";
		String expDsPath = DataUtil.resultPath_exp + "ImportData/SIMPLEJSON/testImportSIMPLEJSON.udb";
		String title = "导入.SIMPLEJSON";

		//新建文件数据源
		CommonOperation.createUDB(resultDsPath);
		//打开建模
		ModelOperation.startModeling();
		//拖拽节点到画布
		ModelTreeOperation modelTreeOperation = new ModelTreeOperation();
		ModelWindowOperation modelWindowOperation = new ModelWindowOperation();
		modelTreeOperation.selectTreeNode("数据导入", "矢量文件", title);
		modelWindowOperation.dragToCanvasPoint(new Point(0, -50));
		//选中节点，设置参数
		Operation operation = new Operation(modelWindowOperation.getContainer());
		modelWindowOperation.clickProcessGraph(title);
		operation.clickRightButtonMenuItem("参数设置");
		DockbarOperation dockbarOperation = new DockbarOperation("参数设置");
		//依次导入点线面
		for (int i = 0; i < 3; i++) {
			modelWindowOperation.clickProcessGraph(title);
			operation.clickRightButtonMenuItem("参数设置");
			dockbarOperation.clickComponent(new NameMatcher("FileChooserControl_button"));
			new JFileChooserOperation().chooseFile(filePaths[i]);
			//点击执行
			ModelOperation.runWorkFlow();
			int state = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(1));
			if (state != TasksManager.WORKFLOW_STATE_COMPLETED) {
				errorCollector.addError(new Throwable("Tasks not fully completed!"));
				modelWindowOperation.collectExceptionProcess(errorCollector);
			}
		}
		//导入文件
		modelWindowOperation.clickProcessGraph(title);
		operation.clickRightButtonMenuItem("参数设置");
		dockbarOperation.clickComponent(new TextMatcher(ProcessProperties.getString("String_Label_SelectFolder")));
		dockbarOperation.clickComponent(new NameMatcher("FileChooserControl_button"));
		new JFileChooserOperation().chooseFile(filePaths[3]);
		//点击执行
		ModelOperation.runWorkFlow();
		int state = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(2));
		if (state != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}

		//结果对比
		Datasource resultDatasource = CommonOperation.getDatasource(0);
		Datasource expDatasource = CommonOperation.openDatasource(expDsPath);
		compareOperation.compareDataset(expDatasource, resultDatasource);
	}

	/**
	 * GJB
	 * fixed 2018.1.12数据集控件为空，组件自动会生成数据集名称，但是现在的版本是，自动加了前缀 NewDataset_陆地交通L；后面几个导入文件夹可能有相同的问题
	 */
	@Test
	public void testImportGJB() throws Exception {
		String filePath = DataUtil.testDataPath + "ImportData/GJB/sm-GJB";
		String resultDsPath = DataUtil.resultPath_actual + "ImportData/GJB/testImportGJB.udb";
		String expDsPath = DataUtil.resultPath_exp + "ImportData/GJB/testImportGJB.udb";
		String title = "导入GJB文件夹";

		//新建文件数据源
		CommonOperation.createUDB(resultDsPath);
		//打开建模
		ModelOperation.startModeling();
		//拖拽节点到画布
		ModelTreeOperation modelTreeOperation = new ModelTreeOperation();
		ModelWindowOperation modelWindowOperation = new ModelWindowOperation();
		modelTreeOperation.selectTreeNode("数据导入", "导入文件夹", title);
		modelWindowOperation.dragToCanvasPoint(new Point(0, -50));
		//选中节点，设置参数
		Operation operation = new Operation(modelWindowOperation.getContainer());
		modelWindowOperation.clickProcessGraph(title);
		operation.clickRightButtonMenuItem("参数设置");
		DockbarOperation dockbarOperation = new DockbarOperation("参数设置");
		dockbarOperation.clickComponent(new NameMatcher("FileChooserControl_button"));
		new JFileChooserOperation().chooseFile(filePath);
		//点击执行
		ModelOperation.runWorkFlow();
		int state = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(5));
		if (state != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}
		//结果对比
		Datasource resultDatasource = CommonOperation.getDatasource(0);
		Datasource expDatasource = CommonOperation.openDatasource(expDsPath);
		compareOperation.compareDataset(expDatasource, resultDatasource);
	}

	/**
	 * GeoDatabase
	 */
	@Test
	public void testImportGeoDatabase() throws Exception {
		String filePath = DataUtil.testDataPath + "ImportData/GeoDatabase";
		String resultDsPath = DataUtil.resultPath_actual + "ImportData/GeoDatabase/testImportGeoDatabase.udb";
		String expDsPath = DataUtil.resultPath_exp + "ImportData/GeoDatabase/testImportGeoDatabase.udb";
		String title = "导入File GeoDataBase Vector 文件夹";

		//新建文件数据源
		CommonOperation.createUDB(resultDsPath);
		//打开建模
		ModelOperation.startModeling();
		//拖拽节点到画布
		ModelTreeOperation modelTreeOperation = new ModelTreeOperation();
		ModelWindowOperation modelWindowOperation = new ModelWindowOperation();
		modelTreeOperation.selectTreeNode("数据导入", "导入文件夹", title);
		modelWindowOperation.dragToCanvasPoint(new Point(0, -50));
		//选中节点，设置参数
		Operation operation = new Operation(modelWindowOperation.getContainer());
		modelWindowOperation.clickProcessGraph(title);
		operation.clickRightButtonMenuItem("参数设置");
		DockbarOperation dockbarOperation = new DockbarOperation("参数设置");
		dockbarOperation.clickComponent(new NameMatcher("FileChooserControl_button"));
		new JFileChooserOperation().chooseFile(filePath);
		//点击执行
		ModelOperation.runWorkFlow();
		int state = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(1));
		if (state != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}

		//忽略属性信息
		modelWindowOperation.clickProcessGraph(title);
		operation.clickRightButtonMenuItem("参数设置");
		dockbarOperation.clickComponent(new NameMatcher(CoreProperties.getString("String_IngoreProperty")));
		//点击执行
		ModelOperation.runWorkFlow();
		state = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(1));
		if (state != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}
		//结果对比
		Datasource resultDatasource = CommonOperation.getDatasource(0);
		Datasource expDatasource = CommonOperation.openDatasource(expDsPath);
		compareOperation.compareDataset(expDatasource, resultDatasource);
	}

	/**
	 * TEMSVector
	 */
	@Test
	public void testImportTEMSVector() throws Exception {
		//只导入点线面和文件夹
		String[] filePaths = {
				DataUtil.testDataPath + "ImportData/TEMSVector/海底地貌及底质L.temsvector",
				DataUtil.testDataPath + "ImportData/TEMSVector/礁石、沉船、障碍物R.temsbuildingvector"};
		String resultDsPath = DataUtil.resultPath_actual + "ImportData/TEMSVector/testImportTEMSVector.udb";
		String expDsPath = DataUtil.resultPath_exp + "ImportData/TEMSVector/testImportTEMSVector.udb";
		String[] titles = {"导入电信 Vector Line 文件夹", "导入电信 Building Vector Region 文件夹"};

		//新建文件数据源
		CommonOperation.createUDB(resultDsPath);
		//打开建模
		ModelOperation.startModeling();
		//拖拽节点到画布
		ModelTreeOperation modelTreeOperation = new ModelTreeOperation();
		ModelWindowOperation modelWindowOperation = new ModelWindowOperation();
		modelTreeOperation.selectTreeNode("数据导入", "导入文件夹", titles[0]);
		modelWindowOperation.dragToCanvasPoint(new Point(0, -100));
		modelTreeOperation.selectTreeNode("数据导入", "导入文件夹", titles[1]);
		modelWindowOperation.dragToCanvasPoint(new Point(0, -50));
		//选中节点，设置参数
		Operation operation = new Operation(modelWindowOperation.getContainer());
		modelWindowOperation.clickProcessGraph(titles[0]);
		operation.clickRightButtonMenuItem("参数设置");
		DockbarOperation dockbarOperation = new DockbarOperation("参数设置");
		//依次导入点线面
		for (int i = 0; i < 2; i++) {
			modelWindowOperation.clickProcessGraph(titles[i]);
			operation.clickRightButtonMenuItem("参数设置");
			dockbarOperation.clickComponent(new NameMatcher("FileChooserControl_button"));
			new JFileChooserOperation().chooseFile(filePaths[i]);
			//设置其中一个电信数据的数据集名称（前缀）
			if (i == 0) {
				dockbarOperation.setTextComponentValue(new NameMatcher(CoreProperties.getString("String_Label_Dataset")), "test");
			}
			//Linux系统需要设置字符集
			if (SystemPropertyUtilities.isLinux()) {
				dockbarOperation.setComboBoxSelectedItem(new NameMatcher(ControlsProperties.getString("String_LabelCharset")), CharsetProperties.getString(CharsetProperties.GB18030));
			}
		}

		//点击执行
		ModelOperation.runWorkFlow();
		int state = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(1));
		if (state != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}

		//结果对比
		Datasource resultDatasource = CommonOperation.getDatasource(0);
		Datasource expDatasource = CommonOperation.openDatasource(expDsPath);
		compareOperation.compareDataset(expDatasource, resultDatasource);
	}

	//======== modeling export ========

	/**
	 * export csv,default,region
	 * @throws Exception
	 */
	@Test
	public void testExportCSV() throws Exception {
		//删除旧文件
		String exportPath = DataUtil.resultPath_actual + "TestExport/testExportCSV";;
		FileUtil.delete(exportPath);
		//打开数据源
		String udbForExport = "SampleData/City/Jingjin.udb";
		CommonOperation.openUDB(DataUtil.testDataPath + udbForExport);
		//拖拽节点，打开参数设置面板
		dragModelExportDataset();
		//选择数据集，参数设置
		setDatasetName("BaseMap_R");
		setExportType(ProcessProperties.getString("String_FileTypeCSV"));
		setDirectory(exportPath);
		//执行
		executeExport(1);
		//结果检查
	}

	/**
	 * export csv,withoutHeader,line
	 * @throws Exception
	 */
	@Test
	public void testExportCSV_withoutHeader() throws Exception {
		//删除旧文件
		String exportPath = DataUtil.resultPath_actual + "TestExport/testExportCSV_withoutHeader";;
		FileUtil.delete(exportPath);
		//打开数据源
		String udbForExport = "SampleData/City/Jingjin.udb";
		CommonOperation.openUDB(DataUtil.testDataPath + udbForExport);
		dragModelExportDataset();

		//选择数据集，参数设置
		setDatasetName("River_L");
		setExportType(ProcessProperties.getString("String_FileTypeCSV"));
		setDirectory(exportPath);
		//不导出表头，取消勾选
		new DockbarOperation("参数设置").clickComponent(new NameMatcher(CoreProperties.getString("String_ExportFieldName")));

		executeExport(1);
		//结果检查
	}

	/**
	 * export csv,filter,point
	 * @throws Exception
	 */
	@Test
	public void testExportCSV_filter() throws Exception {
		//删除旧文件
		String exportPath = DataUtil.resultPath_actual + "TestExport/testExportCSV_filter";;
		FileUtil.delete(exportPath);
		//打开数据源
		String udbForExport = "SampleData/City/Jingjin.udb";
		CommonOperation.openUDB(DataUtil.testDataPath + udbForExport);
		dragModelExportDataset();
		//选择数据集，参数设置
		setDatasetName("BaseMap_P");
		setExportType(ProcessProperties.getString("String_FileTypeCSV"));
		setDirectory(exportPath);
		//设置过滤条件
		new DockbarOperation("参数设置").setTextComponentValue(new NameMatcher(ControlsProperties.getString("String_LabelFilter")), "CODE like \"120%\"");
		executeExport(1);
		//结果检查
	}

	/**
	 * export GEOJSON,default,point
	 * geojson
	 * @throws Exception
	 */
	@Test
	public void testExportGEOJSON() throws Exception {
		//删除旧文件
		String exportPath = DataUtil.resultPath_actual + "TestExport/testExportGEOJSON";;
		FileUtil.delete(exportPath);
		//打开数据源
		String udbForExport = "SampleData/City/Jingjin.udb";
		CommonOperation.openUDB(DataUtil.testDataPath + udbForExport);
		//拖拽功能节点
		dragModelExportDataset();
		//选择数据集，参数设置
		setDatasetName("Neighbor_P");
		setExportType(ProcessProperties.getString("String_FileTypeGEOJSON"));
		setDirectory(exportPath);

		executeExport(1);
		//结果检查
	}

	/**
	 * export GEOJSON,overwrite,region
	 * @throws Exception
	 */
	@Test
	public void testExportGEOJSON_overwrite() throws Exception {
		//删除旧文件
		String exportPath = DataUtil.resultPath_actual + "TestExport/testExportGEOJSON_overwrite";;
		FileUtil.delete(exportPath);
		//打开数据源
		String udbForExport = "SampleData/City/Jingjin.udb";
		CommonOperation.openUDB(DataUtil.testDataPath + udbForExport);
		//拖拽功能节点
		dragModelExportDataset();
		//选择数据集，参数设置
		setDatasetName("Neighbor_R");
		setExportType(ProcessProperties.getString("String_FileTypeGEOJSON"));
		setDirectory(exportPath);
		executeExport(1);
		//覆盖导出
		DockbarOperation.switchDockbar("参数设置");
		new DockbarOperation("参数设置").clickComponent(new NameMatcher(ControlsProperties.getString("string_coverage")));
		executeExport(1);
		//结果检查
	}

	private void dragModelExportDataset() throws ComponentNotFoundException, MultipleComponentsFoundException {
		//建模，拖拽节点
		ModelOperation.startModeling();
		ModelTreeOperation modelTreeOperation = new ModelTreeOperation();
		modelTreeOperation.selectTreeNode("数据导出", "导出矢量数据集");
		ModelWindowOperation modelWindowOperation = new ModelWindowOperation();
		modelWindowOperation.dragToCanvasPoint(new Point(0, 0));
		//选择数据集，设置导出类型
		modelWindowOperation.clickProcessGraph("导出矢量数据集");
		new Operation(modelWindowOperation.getContainer()).clickRightButtonMenuItem("参数设置");
	}
	private void executeExport(int waitMinutes) throws ComponentNotFoundException, MultipleComponentsFoundException, TimeoutException, TimeoutException {
		//点击执行
		ModelOperation.runWorkFlow();
		//等待进度条
		ModelWindowOperation modelWindowOperation = new ModelWindowOperation();
		int i = modelWindowOperation.waitWorkFlowCompleted(TimeUnit.MINUTES.toMillis(waitMinutes));
		if (i != TasksManager.WORKFLOW_STATE_COMPLETED) {
			errorCollector.addError(new Throwable("Tasks not fully completed!"));
			modelWindowOperation.collectExceptionProcess(errorCollector);
		}
	}
	private void setDatasetName(String name) throws ComponentNotFoundException, MultipleComponentsFoundException {
		new DockbarOperation("参数设置").setComboBoxSelectedItem(new NameMatcher(CoreProperties.getString("String_Label_Dataset")), name);
	}
	private void setExportType(String type) throws ComponentNotFoundException, MultipleComponentsFoundException {
		new DockbarOperation("参数设置").setComboBoxSelectedItem(new NameMatcher(ControlsProperties.getString("String_ExportType")), type);
	}
	private void setDirectory(String path) throws ComponentNotFoundException, MultipleComponentsFoundException {
		new DockbarOperation("参数设置").clickComponent(new NameMatcher("FileChooserControl_button"));
		new JFileChooserOperation().chooseDir(path, true);
	}
}
